using System;
using System.Web;

using NHibernate;

namespace Wayloop.Fusion.Data.HttpModules
{
    public class NHibernateSessionModule : IHttpModule
    {
        public void Init(HttpApplication context)
        {
            context.EndRequest += context_EndRequest;
        }


        private void context_EndRequest(object sender, EventArgs e)
        {
            ISession session = NHibernateSessionManager.Session;

            if (session != null)
                session.Close();
        }


        public void Dispose()
        {
            throw new NotImplementedException();
        }
    }
}